package com.zzu.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.Lifecycle;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.zzu.view.fragment.ExpressInfoFragment;
import com.zzu.view.fragment.MapFragment;
import com.zzu.view.fragment.TransportInfoFragment;
import com.zzu.view.fragment.TransportMapFragment;

/**
 * @ClassName TransportAdapter
 * @Description TODO
 * @Author ZB
 * @Date 2021/5/23 16:14
 * @Version 1.0
 **/
public class TransportAdapter extends FragmentStateAdapter {

    //传入当前的包裹单号
    String packageId = "1234567891234";//默认的fragment
    String status = "3";
    public TransportAdapter(@NonNull FragmentManager fragmentManager, @NonNull Lifecycle lifecycle, String packageId,String status) {
        super(fragmentManager, lifecycle);
        this.packageId = packageId;
        this.status = status;
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        if(position == 0){
            //返回显示详细信息的fragment
            return TransportInfoFragment.newInstance(packageId,status);
        }else{
            //返回显示地图的fragment
            return TransportMapFragment.newInstance();
        }
    }


    //一共有两个fragment
    @Override
    public int getItemCount() {
        return 2;
    }
}
